<?php

/**
 * @package Framework03
 * @author Walter Tamboer
 */

/**
 * Helper class for some common things.
 */
final class Utils extends Object
{
	/**
	 * Redirect to another page
	 */
	public static function Redirect($url)
	{
		// TODO: Make this work in older browsers

		header('Location:' . $url);
		exit;
	}
	/**
	 * Debug some PHP stuff
	 * @param mixed $input
	 */
	public static function Debug($input)
	{
		echo '<pre>';
		print_r($input);
		echo '</pre>';
	}
	/**
	 * Get the current IP address
	 * @return string
	 */
	public static function GetIp()
	{
		return isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
	}
	/**
	 * Strips all the slashes from the given data.
	 * @return array
	 */
	public static function AddSlashes($Data)
	{
		if (is_array($Data))
		{
			foreach ($Data as $K => $V)
				$Data[$K] = self::AddSlashes($V);
		}
		else
			$Data = addslashes($Data);
		
		return $Data;
	}
	/**
	 * Strips all the slashes from the given data.
	 * @return array
	 */
	public static function StripSlashes($Data)
	{
		if (is_array($Data))
		{
			foreach ($Data as $K => $V)
				$Data[$K] = self::StripSlashes($V);
		}
		else
			$Data = stripslashes($Data);
		
		return $Data;
	}
}

?>